using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.Messages.Entity
{
    [Table("MessageAttachment", "", "Wicresoft.Messages.ConnectionString")]
    public class MessageAttachment : Info
    {
        #region SQL column name consts
        public const string SQLCOL_ID = "ID";
        public const string SQLCOL_MESSAGEID = "MessageID";
        public const string SQLCOL_ORIGINALFILENAME = "OriginalFileName";
        public const string SQLCOL_URL = "Url";
        public const string SQLCOL_FILEPATH = "FilePath";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public MessageAttachment() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public MessageAttachment(Guid ID)
        {
            this.ID = ID;
        }
        #endregion

        public override void Init(DataRow row)
        {
            ID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_ID]);
            MessageID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_MESSAGEID]);
            OriginalFileName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_ORIGINALFILENAME]);
            Url = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_URL]);
            FilePath = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_FILEPATH]);
        }

        #region Properties
        #region Property <Guid> ID
        [Property("ID", 16, SqlDbType.UniqueIdentifier, false, true)]
        public Guid ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private Guid _ID = Guid.Empty;
        #endregion

        #region Property <Guid> MessageID
        [Property("MessageID", 16, SqlDbType.UniqueIdentifier, false, false)]
        public Guid MessageID
        {
            get { return _MessageID; }
            set { _MessageID = value; }
        }
        private Guid _MessageID = Guid.Empty;
        #endregion

        #region Property <string> OriginalFileName
        [Property("OriginalFileName", 400, SqlDbType.NVarChar, false, false)]
        public string OriginalFileName
        {
            get { return _OriginalFileName; }
            set { _OriginalFileName = value; }
        }
        private string _OriginalFileName = null;
        #endregion

        #region Property <string> Url
        [Property("Url", 2147483646, SqlDbType.NText, false, false)]
        public string Url
        {
            get { return _Url; }
            set { _Url = value; }
        }
        private string _Url = null;
        #endregion

        #region Property <string> FilePath
        [Property("FilePath", 2147483646, SqlDbType.NText, false, false)]
        public string FilePath
        {
            get { return _FilePath; }
            set { _FilePath = value; }
        }
        private string _FilePath = null;
        #endregion
        #endregion




    }
}
